home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 015 / prtset.arc / PRTSET.C next >
Text File  |  1986-05-28  |  2KB  |  89 lines

  1. /* This program is called to send a code to the IBM/Epson printer family
  2.  *  it sets unp printer for squeezed, emphasized, double width, double strike,
  3.  *      or normal print; it also sends carriage return and formfeed.
  4.  *  usage: PRTSET [-]{s b n c f e d}  
  5.  *      s=squeeze  e=emphasize  d=double strike  n=normal
  6.  *      b=double width  c=<CR>  f=<FORMFEED>
  7.  *      -option undoes option
  8.  *  c.1986 w.borys
  9.  */
  10. #include "std.h"
  11.  
  12. #define SQ "\017\0330"
  13. #define SOQ "\022\0332"
  14. #define BG "\033W\001"
  15. #define BOG "\033W\000"
  16. #define CR "\012\015"
  17. #define FF "\014" 
  18. #define EM "\033E" 
  19. #define EOM "\033F" 
  20. #define DS "\033G" 
  21. #define DOS "\033H" 
  22.  
  23. TEXT *pr[] = { SQ, SOQ, BG, BOG, EM, EOM, DS,DOS, CR, FF };
  24. COUNT nc[] = { 3,3,3,3,2,2,2,2,2,1 };
  25. main(ac,av)
  26.     COUNT ac;
  27.     TEXT *av[];
  28.     {
  29.     TEXT c;
  30.     COUNT index, offset, iend, fd;
  31.  
  32.     c = toupper(av[1][0]);
  33.     index = 99;
  34.     offset = 0;
  35.  
  36.     if (c == '-')
  37.         {
  38.         offset = 1;
  39.         c = toupper(av[1][1]);
  40.         }
  41.  
  42.     switch ((COUNT) c)
  43.         {
  44.         case 'S':
  45.             index = 0;
  46.             break;
  47.         case 'B':
  48.             index = 2;
  49.             break;
  50.         case 'E':
  51.             index = 4;
  52.             break;
  53.         case 'D':
  54.             index = 6;
  55.             break;
  56.         case 'C':
  57.             index = 8;
  58.             break;
  59.         case 'F':
  60.             index = 9;
  61.             break;
  62.         case 'N':
  63.             index = 10;
  64.             break;
  65.         }    
  66.  
  67.     if (index == 99)
  68.         {
  69.      printf("usage: PRTSET {s b e d c f n} \n");
  70.      printf("set up IBM printer from keyboard or batch file\n");
  71.      printf("s=small  e=emphasized  d=double strike  b=double width\n");
  72.      printf("  n=normal    -option  undoes option \n");
  73.      printf("  c=<CR>  f=<FORMFEED>      c1986 borysoft\n");
  74.      exit(0);
  75.         }
  76.     else
  77.         {
  78.         index += offset;
  79.         iend = index;
  80.         if (index >= 10)
  81.             index=1,iend=7;
  82.         fd=open("PRN:", BWRITE);
  83.         for (offset = index; offset <= iend; offset+=2)
  84.             write(fd,pr[offset],nc[offset]);
  85.         close(fd);
  86.         }
  87.     }
  88.  
  89.